//
//  UIImageView+Utility.m
//  OceanStaffApp
//
//  Created by Zheng on 2019/7/31.
//  Copyright © 2019 Zh. All rights reserved.
//

#import "UIImageView+Utility.h"

@implementation UIImageView (Utility)

- (void)zh_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
    @weakify(self);
    [self sd_setImageWithURL:url placeholderImage:placeholder completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        @strongify(self);
        if (image && cacheType == SDImageCacheTypeNone) {
            CATransition *transition = [CATransition animation];
            transition.type = kCATransitionFade;
            transition.duration = 0.4;
            transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            [self.layer addAnimation:transition forKey:nil];
        }
    }];
}

@end
